import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @Auther: MFM
 * @Date: 2021/7/22 - 07 - 22 - 16:18
 * @version: 1.0
 */

public class ListDemo {
    public static class Student {
        private String name;
        private String gender;
        private int cn;
        private int math;
        private int en;
        private int total;

        public Student() {
        }

        public Student(String name, String gender, int cn, int math, int en) {
            this.name = name;
            this.gender = gender;
            this.cn = cn;
            this.math = math;
            this.en = en;
            this.total = cn + math + en;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getGender() {
            return gender;
        }

        public void setGender(String gender) {
            this.gender = gender;
        }

        public int getCn() {
            return cn;
        }

        public void setCn(int cn) {
            this.cn = cn;
        }

        public int getMath() {
            return math;
        }

        public void setMath(int math) {
            this.math = math;
        }

        public int getEn() {
            return en;
        }

        public void setEn(int en) {
            this.en = en;
        }

        public int getTotal() {
            return total;
        }

        public void setTotal(int total) {
            this.total = total;
        }

        @Override
        public String toString() {
            return "姓名:" + name + "==总成绩:" + total;
        }
    }

    public static void main(String[] args) throws Exception {
        List<Student> students = new ArrayList<>();
        Scanner scanner = new Scanner(new File("./file/aa.txt"));
        while (scanner.hasNext()) {
            String string = scanner.nextLine();
            String[] str = string.split("，");
            Student stu = new Student(str[0], str[1], Integer.parseInt(str[2]), Integer.parseInt(str[3]), Integer.parseInt(str[4]));
            students.add(stu);
        }
        scanner.close();

        for (int i = 0; i <students.size() ; i++) {
            for (int j = i+1; j <students.size() ; j++) {
                if (students.get(i).getTotal()<students.get(j).getTotal()){
                    Student student = students.get(i);
                    students.set(i,students.get(j));
                    students.set(j,student);
                }
            }
        }
        students.forEach(System.out::println);
    }
}
